package com.xsmart.order.dao;

import com.baomidou.mybatisplus.plugins.Page;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author DIYC
 */
@Component
public interface AdConfigruationDao {
    /**
     * 查找
     * @param page
     * @param adConfigruationMap
     * @return
     */
    @Select("<script>" +
            "select * from yy_seat where 1=1" +
            "<if test=\"seat_code != null and seat_code != ''\">" +
            "and seat_code=#{seat_code}" +
            "</if>" +
            "<if test=\"seat_type != null\">" +
            "and seat_type=#{seat_type}" +
            "</if>" +
            "</script>")
    List<Map<String, Object>> queryAdConfigruation(Page<Map<String, Object>> page, Map adConfigruationMap);

    /**
     * 查询id和编码与名称
     * @return
     */
    @Select("select seat_id as value," +
            "concat(seat_code,\"-\",seat_name) as label from yy_seat")
    List<Map<String, Object>> queryAllAdConfigruation();

    /**
     * 新增
     * @param adConfigruationMap
     * @return
     */
    @Insert("insert into yy_seat" +
            "(seat_code," +
            "seat_name," +
            "seat_type)" +
            "values(" +
            "#{adConfigruationMap.seat_code}," +
            "#{adConfigruationMap.seat_name}," +
            "#{adConfigruationMap.seat_type})")
    int addAdConfigruation(@Param("adConfigruationMap")Map adConfigruationMap);

    /**
     * 更新
     * @param adConfigruationMap
     * @return
     */
    @Update("update yy_seat set seat_code=#{adConfigruationMap.seat_code}," +
            "seat_name=#{adConfigruationMap.seat_name}," +
            "seat_type=#{adConfigruationMap.seat_type} " +
            "where seat_id=#{adConfigruationMap.seat_id}")
    int modAdConfigruation(@Param("adConfigruationMap")Map adConfigruationMap);

    /**
     * 删除
     * @param seatid
     * @return
     */
    @Delete("delete from yy_seat where seat_id=#{seatid}")
    int delAdConfigruation(Integer seatid);
}
